﻿using System;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TrainingCenterSystem.UserManagement;

namespace TrainingCenterSystem
{
    /// <summary>
    /// Represents the different language settings
    /// </summary>
    public enum LanguageSetting
    {
        English,
        Swedish,
        German
    }

    /// <summary>
    /// Represents a system-wide instance, that is used for storing data relevant throughout the system.
    /// </summary>
    public class TrainingCenter
    {
        #region private members
        private string[] _availableLanguages;
        private string[] _languageIDs;
        private LanguageSetting _currentLanguage;
        private string _currentLanguageID;
        private User _currentUser;
        private ArrayList _availableUsers;
        private List<Supervisor> _approvalList;
        private bool _isBasicVersion;
        #endregion

        #region setters and getters
        /// <summary>
        /// Gets the available languages as string-Array.
        /// </summary>
        public string[] AvailableLanguages
        {
            get { return _availableLanguages; }
        }

        /// <summary>
        /// Gets the available language ids.
        /// </summary>
        public string[] LanguageIDs
        {
            get { return _languageIDs; }
        }

        /// <summary>
        /// Gets or sets the id of the currently selected language.
        /// </summary>
        public string CurrentLanguageID
        {
            get { return _currentLanguageID; }
            set { _currentLanguageID = value; }
        }

        /// <summary>
        /// Gets or sets the current user.
        /// </summary>
        public User CurrentUser
        {
            get { return _currentUser; }
            set { _currentUser = value; }
        }

        public ArrayList AvailableUsers
        {
            set { _availableUsers = value; }
            get { return _availableUsers; }
        }

        public List<Supervisor> ApprovalList
        {
            get { return _approvalList; }
            set { _approvalList = value; }
        }

        public bool IsBasicVersion
        {
            get { return _isBasicVersion; }
        }
        #endregion

        #region constructor(s)
        /// <summary>
        /// Creates an instance of TrainingCenter with a supervisor as default.
        /// </summary>
        public TrainingCenter()
        {
            this.initLanguages();
            //_currentUser = new TrainingCenterSystem.UserManagement.Supervisor("001","test");
            _availableUsers = new ArrayList();
            _approvalList = new List<Supervisor>();
            _isBasicVersion = true;
            //_availableUsers.Add(_currentUser);
        }

        /// <summary>
        /// Creates an instance of TrainingCenter with a specific user.
        /// </summary>
        /// <param name="user">The current user</param>
        public TrainingCenter(User user)
        {
            this.initLanguages();
            _currentUser = user;
        }
        #endregion

        #region methods
        /// <summary>
        /// initializes the language options
        /// </summary>
        private void initLanguages()
        {
            _availableLanguages = new string[3];
            _languageIDs = new string[3];

            _availableLanguages[0] = "English";
            _availableLanguages[1] = "Swedish";
            _availableLanguages[2] = "German";

            _languageIDs[0] = "en-GB";
            _languageIDs[1] = "se-SE";
            _languageIDs[2] = "de-DE";
        }
        
        /// <summary>
        /// Sets the current UI language
        /// </summary>
        /// <param name="languageIndex">the language index</param>
        public void SetLanguage(int languageIndex)
        {
            if (languageIndex == 1)
            {
                _currentLanguage = LanguageSetting.Swedish;
                _currentLanguageID = _languageIDs[1];
            }
            else if (languageIndex == 2)
            {
                _currentLanguage = LanguageSetting.German;
                _currentLanguageID = _languageIDs[2];
            }
            else
            {
                _currentLanguage = LanguageSetting.English;
                _currentLanguageID = _languageIDs[0];
            }
        }
        #endregion
    }
}
